import request from '@/router/axios'
import store from '@/store';
import moment from 'moment';
import {
  getMappingStatus,
  fenExYuangettoFixed,
  getSysUserToLS,
  getLineName,
  getStationName,
  xieChaStatus,
  getXieChaStatusFormat,
  getSCOrLCOrACC,
  getMappingStatusArray,
  allStatus,
  getNewMappingStatusArray
} from "../../../../../subwayRat/commonCheck";

export function get_xw_SwAuTvmCashAmountHierarchyDifferenceList(param) {
  return request({
    url: '/check/checkNew/get_xw_SwAuTvmCashAmountHierarchyDifferenceList',
    method: 'post',
    data: param,
    params: param
  })
}


/**
 * 其他运营中心列表
 * @param query
 */
 export function getSwAuTvmCashboxAmountHierarchyDifferenceListOther(query) {
  return request({
    url: '/check/checkNew/get_xw_SwAuTvmCashAmountHierarchyDifferenceListOther',
    method: 'post',
    params: query,
    data:query
  })
}

/**
 * 回馈原因，金额
 * @param param
 */
export function replaySwAuTvmCashAmountHierarchyDifference(param) {
  return request({
    url: '/check/checkNew/replaySwAuTvmCashAmountHierarchyDifference',
    method: 'post',
    params:param,
    data:param
  })
}

/**
 * 提交功能
 * @param param
 */
export function submitSwAuTvmCashAmountHierarchyDifference(param) {
  return request({
    url: '/check/checkNew/submitSwAuTvmCashAmountHierarchyDifference',
    method: 'post',
    data:param,
    params:param
  })
}
//批量回馈
export function replaySwAuTvmCashAmountHierarchyDifferenceList(param) {
  return request({
    url: '/check/checkNew/replaySwAuTvmCashAmountHierarchyDifferenceList',
    method: 'post',
    data:param,
    params:param
  })
}
/**
 * 导出
 * @param query
 */
 export function exportTvmCashAmountHierarchy(query) {
  return request({
    url: '/check/checkNew/exportTvmCashAmountHierarchy',
    method: 'get',
    params: query,
    responseType:'blob'
  })
}

/**
 * 撤回TVM层级差异
 * @param query
 */
 export function revokeTvmCengJi(query) {
  return request({
    url: '/check/checkNew/revokeTvmCengJi',
    method: 'post',
    params: query,
    data:query,
  })
}

export const table_XT_CJCY_Option = {
  border: true,
  index: true,
  indexLabel: '序号',
  selection: true,
  reserveSelection:false,
  stripe: true,
  menuAlign: 'center',
  viewBtn: false,
  editBtn: false,
  emptyBtn:false,
  delBtn: false,
  align: 'center',
  addBtn: false,
  height: 450,
  column: [{label:"线路",
    "prop":"lineCode",type:'select',search:true,searchslot:true,formatter: function(row, value , label, column){
      return getLineName(value);
    }},
    {label:"站点",
      "prop":"stationCode",type:'select',search:true,searchslot:true,formatter: function(row, value , label, column){
        return getStationName(row.lineCode,value);
      }},
    {label:"收入日期",format: 'yyyy-MM-dd',
    valueFormat: 'yyyy-MM-dd',type:'date',
      "prop":"settleTime",search:true,width:90},
    {label:"TVM编号",
      "prop":"tvmOrder",type:'select',search:true,searchslot:true},
    {label:"支付方式",
      "prop":"payType",type:'select',dicData:getMappingStatusArray('xw_pay_type'),search:false,formatter:function (row,v) {
          return getMappingStatus('xw_pay_type',v);
      },hide: true},
      {label:"SC售卖金额",width:120,
        "prop":"saleAmount",formatter:function (row,value , label, column) {
          return fenExYuangettoFixed(row,'saleAmount');
        }},
      {label:"SC充值金额",width:120,
      "prop":"depositAmount",formatter:function (row,value , label, column) {
        return fenExYuangettoFixed(row,'depositAmount');
      }},
    {label:"SC退款金额",width:120,
      "prop":"errorRefundAmount",formatter:function (row,value , label, column) {
        return fenExYuangettoFixed(row,'errorRefundAmount');
      }},
      {label:"LC售卖金额",width:120, "prop":"beSaleAmount",formatter:function (row,value , label, column) {
          return fenExYuangettoFixed(row,'beSaleAmount');
        }},
    {label:"LC充值金额",width:120, "prop":"beDepositAmount",formatter:function (row,value , label, column) {
        return fenExYuangettoFixed(row,'beDepositAmount');
      }},
    {label:"LC退款金额",width:120, "prop":"beErrorRefundAmount",formatter:function (row,value , label, column) {
        return fenExYuangettoFixed(row,'beErrorRefundAmount');
      }},
      {label:"售卖差异金额",width:120, "prop":"shoumaichayi",formatter:function(row, value , label, column){
          let chaYi = getChaYi(row,'saleAmount','beSaleAmount');
          row.shoumaichayi=chaYi;
          return fenExYuangettoFixed(row,'shoumaichayi');
        }},
    {label:"充值差异金额",width:120, "prop":"chongzhichayi",formatter:function(row, value , label, column){
        let chaYi = getChaYi(row,'depositAmount','beDepositAmount');
        row.chongzhichayi=chaYi;
        return fenExYuangettoFixed(row,'chongzhichayi');
      }},
    {label:"退款差异金额",width:120, "prop":"guzhangtuikuanchayi",formatter:function(row, value , label, column){
        let chaYi = getChaYi(row,'errorRefundAmount','beErrorRefundAmount');
        row.guzhangtuikuanchayi=chaYi;
        return fenExYuangettoFixed(row,'guzhangtuikuanchayi');
      }},
    {label:"协查状态",
      "prop":"assistStatus",type:'select',search:true,dicData:xieChaStatus(),
      formatter:function(row, value , label, column){
        return getXieChaStatusFormat(value);
      }},
    {label:"通知时间",
      "prop":"sendAssistTime",
      // formatter:function (row,v) {
      //   return moment(v).format("YYYY-MM-DD");
      // }
      type: 'date',width:90,
      format: 'yyyy-MM-dd',
      valueFormat: 'yyyy-MM-dd',
      search: true},
    {label:"机电回馈差异原因",
    width: 120,dicData: getMappingStatusArray('JD_REPLY_REASON'),search:true,type: 'select',
      "prop":"jdReplyReason",formatter:function (row,v) {
      return getMappingStatus('JD_REPLY_REASON',v);
    }},
    {label:"机电专业详细描述",
      "prop":"jdReplyDetail",hide: true}]
};

// function getChaYi(row,compareFirst,compareSec){ //结账金额 sc 差额
//   let first=getLcOrScAmount('','',row[compareFirst]);//结账金额
//   let sec=getLcOrScAmount(row.compareType,2,row[compareSec]); //sc
//   return sec-first;
// }

function getChaYi(row,compareFirst,compareSec){ //sc lc差额
  let first = getLcOrScAmount('','',row[compareFirst]);//sc
  let sec = getLcOrScAmount(row.compareType,3,row[compareSec]); //lc
  return first-sec;
}

function getLcOrScAmount(originType,needType,thisData){ //结账金额或者 sc
  if((originType+"")==(needType+"")){
    return thisData;
  }else{
    return 0;
  }
}





export function getMondifyData1(ob){
  console.log(ob)
  let one={};
  let two={};

  if(ob.compareType==3){ //SC与LC
    one.type="SC";
    two.type="LC";
  }else if(ob.compareType==4){//LC与ACC
    one.type="LC";
    two.type="ACC";
  }
  one.saleAmount=ob.saleAmount;
  one.saleAmountCY='';
  one.depositAmount=ob.depositAmount;
  one.depositAmountCY='';
  one.errorRefundAmount=ob.errorRefundAmount;
  one.errorRefundAmountCY='';
  one.sumCY='';

  two.saleAmount=ob.beSaleAmount;
  two.saleAmountCY=ob.saleAmount-ob.beSaleAmount;
  two.depositAmount=ob.beDepositAmount;
  two.depositAmountCY=ob.depositAmount-ob.beDepositAmount;
  two.errorRefundAmount=ob.beErrorRefundAmount;
  two.errorRefundAmountCY=ob.errorRefundAmount-ob.beErrorRefundAmount;
  two.sumCY=(ob.saleAmount-ob.beSaleAmount)+(ob.depositAmount-ob.beDepositAmount)-(ob.errorRefundAmount-ob.beErrorRefundAmount);

  // one.type="结账单据";
  // one.saleAmount=ob.tvmBillCashSellTicket;
  // one.saleAmountCY='';
  // one.depositAmount=ob.tvmBillCashRecharge;
  // one.depositAmountCY='';
  // one.errorRefundAmount=ob.tvmBillCashReturn;
  // one.errorRefundAmountCY='';
  // one.sumCY='';

  // two.type=getSCOrLCOrACC(ob.compareType);
  // two.saleAmount=ob.beSaleAmount;
  // two.saleAmountCY=ob.beSaleAmount-ob.tvmBillCashSellTicket;
  // two.depositAmount=ob.beDepositAmount;
  // two.depositAmountCY=ob.beDepositAmount-ob.tvmBillCashRecharge;
  // two.errorRefundAmount=ob.beErrorRefundAmount;
  // two.errorRefundAmountCY=ob.beErrorRefundAmount-ob.tvmBillCashReturn;
  // two.sumCY=(ob.beSaleAmount-ob.tvmBillCashSellTicket)+(ob.beDepositAmount-ob.tvmBillCashRecharge)-(ob.beErrorRefundAmount-ob.tvmBillCashReturn);

  let res=[];
  res.push(one);
  res.push(two);
  return res;
}

export const cols1={
  border: true,
  index: false,
  indexLabel: '序号',
  selection: false,
  reserveSelection:false,
  stripe: false,
  menu:false,
  header:false,
  menuAlign: 'center',
  viewBtn: false,
  editBtn: false,
  emptyBtn:false,
  delBtn: false,
  align: 'center',
  addBtn: false,
  column: [{
  label: '系统层级',
  prop: "type",
  formslot: true,
},
  {
    label: '售票金额',
    prop: "saleAmount",
    formatter:function (row,v,label,col) {
      return fenExYuangettoFixed(row,col.prop);
    }
  },
  {
    label: '售票差异金额',
    width:120,
    prop: "saleAmountCY",
    formatter:function (row,v,label,col) {
      return fenExYuangettoFixed(row,col.prop);
    }
  },
  {
    label: '充值金额',
    prop: "depositAmount",
    formatter:function (row,v,label,col) {
      return fenExYuangettoFixed(row,col.prop);
    }
  },
  {
    label: '充值差异金额',
    width:120,
    prop: "depositAmountCY",
    formatter:function (row,v,label,col) {
      return fenExYuangettoFixed(row,col.prop);
    }
  },
  {
    label: '退款金额',
    prop: "errorRefundAmount",
    formatter:function (row,v,label,col) {
      return fenExYuangettoFixed(row,col.prop);
    }
  },

  {
    label: '退款差异金额',
    width:120,
    prop: "errorRefundAmountCY",
    formatter:function (row,v,label,col) {
      return fenExYuangettoFixed(row,col.prop);
    }
  },
  {
    label: '票款合计差异',
    width:120,
    prop: "sumCY",
    formatter:function (row,v,label,col) {
      return fenExYuangettoFixed(row,col.prop);
    }
  }]
}

export const cols2={
  border: true,
  index: false,
  header:false,
  indexLabel: '序号',
  selection: false,
  reserveSelection:false,
  stripe: false,
  menu:false,
  menuAlign: 'center',
  viewBtn: false,
  editBtn: false,
  emptyBtn:false,
  delBtn: false,
  align: 'center',
  addBtn: false,
  column: [
  {
    label: '回馈售票金额',
    prop: "replySaleMoney",
    cell:true,
    type:'number',
    precision:2,
  },
  {
    label: '回馈充值金额',
    prop: "replyRechargeMoney",
    cell:true,
    type:'number',
    precision:2,
  },
  {
    label: '回馈退款金额',
    prop: "replyErrorReturnMoney",
    cell:true,
    type:'number',
    precision:2,
  },]
};


